home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
576-600
/
592
/
star
/
star.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-15
|
872b
|
67 lines
#include <math.h>
#include <exec/memory.h>
void Free_Values(int *p)
{
int points;
points=p[0];
FreeMem(p,(points*2+2)*sizeof(int *));
return;
}
int Draw_Star(struct RastPort *rastport,int *p,int x,int y,int count)
{
int x1,y1,points,w;
if(p==NULL) return(0);
x1=x-160;
y1=y-128;
points=p[0];
count=count%points;
w=count;
Move(rastport,p[1]+x1,p[points+1]+y1);
Draw(rastport,p[1+w]+x1,p[points+1+w]+y1);
while(w)
{
w+=count;
w=w%points;
Draw(rastport,p[1+w]+x1,p[1+points+w]+y1);
}
return(1);
}
int *Init_Values(int radius,int points)
{
int n,*p;
float incr;
p=(int *)AllocMem(sizeof(int *)*(points*2+2),MEMF_PUBLIC+MEMF_CLEAR);
if(p==NULL) return(0);
p[0]=points;
incr=2.0*3.141592654/points;
for(n=1;n<=points;n++)
{
p[n]=floor(radius*cos(n*incr)+160);
p[n+points]=floor(radius*sin(n*incr)+128);
}
return((int *)p);
}